/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.service.impl;

import com.qdu.dao.MovieDao;
import com.qdu.dao.impl.MovieDaoImpl;
import com.qdu.entity.Movie;
import com.qdu.service.MovieService;
import java.util.List;

/**
 *
 * @author Lenovo
 */
public class MovieServiceImpl implements MovieService{
MovieDao movieDao = new MovieDaoImpl();
    @Override
    public List<Movie> findAllMovies() {
         return movieDao.getAllMovies();
    }

    @Override
    public List<Movie> findMoviesByKeyword(String keyword) {
         return movieDao.getMoviesByKeyword(keyword);
    }

    @Override
    public Movie findMovieById(String movieId) {
          Movie movie = movieDao.getMovieInfoById(movieId);
          return movie;
    }
   

    @Override
    public int registerNewMovie(Movie m) {
         Movie movie=movieDao.getMovieInfoById(m.getMovieId());
        if(null==movie){
            return movieDao.insert(m);
        }else{
            return -1;
        }
    }

    @Override
    public int modifyMovieInfo(Movie m) {
        return movieDao.update(m);
    }

    @Override
    public int unregister(String movieId) {
        return movieDao.deleteByMovieId(movieId);
    }
}
